// pages/orderDetail/orderDetail.js
const app = getApp()
const Utils = require("../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:'',
    name:"",
    state:"",
    state_text:'',
    phone:"",
    card:"",
    yajin:"",
    starttime:"",
    endtime:"",
    day:"",
    creattime:"",
    code:"",
    overtime_text:'',
    room_number:'',
    isrz:'none',
    isld:'none',
    isjd:'none',
    isjj:'none',
    value:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id:options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    let userId = wx.getStorageSync('userId')
    let params={
      order_id:that.data.id
    }
    Utils.getDataRequest('?s=App.Merchant_Order.GrtorderInfo', params, function success(res) {
      console.log(res)
      that.setData({
        name: res.data.standby_7,
        state:res.data.state,
        state_text: res.data.state_text,
        phone: res.data.tel,
        card: res.data.standby_8,
        yajin: res.data.deposit_money,
        starttime: res.data.start_time,
        endtime: res.data.end_time,
        day: res.data.day,
        creattime: res.data.creat_time,
        code:res.data.code,
        overtime_text:res.data.overtime_text,
        room_number:res.data.room_number
      })
    }, function fail(res) {
      //失败回调
      
    }, 'hotel')
  },
  ruzhu(){
    this.setData({
      isrz:'block',
    })
  },
  lidian(){
    this.setData({
      isld:'block',
    })
  },
  jieshou(){
    this.setData({
      isjd:'block'
    })
  },
  jujue(){
    this.setData({
      isjj:'block'
    })
  },
  bindinput(e){
    console.log(e.detail.value)
    this.setData({
      value:e.detail.value
    })
  },
  rzCancel() {
    this.setData({
      isrz:'none',
      value:''
    })
  },
  rzSure(){
    let userId = wx.getStorageSync('userId')
    let that = this
    let params={
      enterprise_basic_info_id: userId,
      order_id: that.data.id,
      room_number:that.data.value
    }
    Utils.getDataRequest('?s=App.Merchant_Order.Check_in', params, function success(res) {
      console.log(res)
      that.setData({
        isrz:'none'
      })
      wx.showToast({
        title: res.data.msg,
        icon: 'none',
        duration: 1000
      })
      
      //成功回调
    }, function fail(res) {
      //失败回调
    }, 'hotel')
  },
  ldCancel() {
    this.setData({
      isld:'none',
    })
  },
  ldSure(){
    let userId = wx.getStorageSync('userId')
    let that = this
    let params={
      enterprise_basic_info_id: userId,
      order_id: that.data.id,
    }
    Utils.getDataRequest('?s=App.Merchant_Order.Finish_order', params, function success(res) {
      console.log(res)
      that.setData({
        isld:'none'
      })
      wx.showToast({
        title: res.data.msg,
        icon: 'none',
        duration: 1000
      })
      
      //成功回调
    }, function fail(res) {
      //失败回调
    }, 'hotel')
  },
  jdCancel() {
    this.setData({
      isjd:'none',
    })
  },
  jdSure(){
    let userId = wx.getStorageSync('userId')
    let that = this
    let params={
      enterprise_basic_info_id: userId,
      order_id: that.data.id,
    }
    Utils.getDataRequest('?s=App.Merchant_Order.Confirm_order', params, function success(res) {
      console.log(res)
      that.setData({
        isjd:'none'
      })
      wx.showToast({
        title: res.data.msg,
        icon: 'none',
        duration: 1000
      })
      
      //成功回调
    }, function fail(res) {
      //失败回调
    }, 'hotel')
  },
  jjCancel() {
    this.setData({
      isjj:'none',
    })
  },
  jjSure(){
    let userId = wx.getStorageSync('userId')
    let that = this
    let params={
      enterprise_basic_info_id: userId,
      order_id: that.data.id,
    }
    Utils.getDataRequest('?s=App.Merchant_Order.Remove_order', params, function success(res) {
      console.log(res)
      that.setData({
        isjj:'none'
      })
      wx.showToast({
        title: res.data.msg,
        icon: 'none',
        duration: 1000
      })
      
      //成功回调
    }, function fail(res) {
      //失败回调
    }, 'hotel')
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})